﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace _201206QuanLyBanHang.ChucNang
{
    class BLL_DMDautu
    {
        DataConn da;
        public BLL_DMDautu()
        {
            da = new DataConn();
        }
        public DataSet getDMDautu(string strsql)
        {
            return da.ExectueQueryDataset(strsql, CommandType.Text, null);
        }
        public bool insertDMDautu(ref string err, int madanhmuc,int madt, string tendanhmuc,string ghichu)
        {
            return da.MyExecuteNonQuery("Pro_Insert_DMDautu", CommandType.StoredProcedure, ref err, new SqlParameter("@madanhmuc", madanhmuc), new SqlParameter("@madautu", madt),new SqlParameter("tendanhmuc",tendanhmuc), new SqlParameter("@ghichu", ghichu));
        }
        public bool deleteDMDautu(ref string err, int madanhmuc)
        {
            return da.MyExecuteNonQuery("Pro_Delete_DMDautu", CommandType.StoredProcedure, ref err, new SqlParameter("@madanhmuc",madanhmuc));
        }
        public bool updateDMDautu(ref string err, int madanhmuc, int madt, string tendanhmuc, string ghichu)
        {
            return da.MyExecuteNonQuery("Pro_Update_DMDautu", CommandType.StoredProcedure, ref err, new SqlParameter("@madanhmuc", madanhmuc), new SqlParameter("@madautu", madt), new SqlParameter("tendanhmuc", tendanhmuc), new SqlParameter("@ghichu", ghichu));
        }
        public object layma(ref string err, string str)
        {

            return da.lay(str, CommandType.Text, ref err);


        }
        public void fillCombo(string sql, ComboBox cmb, string text, string value)
        {
            DataSet ds = new DataSet();
            ds = da.ExectueQueryDataset(sql, CommandType.Text, null);

            cmb.DataSource = ds.Tables[0];
            cmb.DisplayMember = text;
            cmb.ValueMember = value;
        }
    }
}
